using MediatR;
using RBAC.ErrorCode;
using Microsoft.AspNetCore.Http;

namespace RBAC.Write.Api.Application.Command.ERP.MaterialFile
{
    /// <summary>
    /// 导入物料分类命令
    /// </summary>
    public class ImportMaterTypeCommand : IRequest<APIResult<ImportResultDto>>
    {
        /// <summary>
        /// Excel文件
        /// </summary>
        public IFormFile File { get; set; } = null!;
    }

    /// <summary>
    /// 导入结果DTO
    /// </summary>
    public class ImportResultDto
    {
        /// <summary>
        /// 成功导入的行数
        /// </summary>
        public int SuccessCount { get; set; }

        /// <summary>
        /// 失败导入的行数
        /// </summary>
        public int FailCount { get; set; }

        /// <summary>
        /// 错误详情列表
        /// </summary>
        public List<ImportErrorDetail> ErrorDetails { get; set; } = new();

        /// <summary>
        /// 导入成功的数据预览
        /// </summary>
        public List<MaterTypeImportPreview> PreviewData { get; set; } = new();
    }

    /// <summary>
    /// 导入错误详情
    /// </summary>
    public class ImportErrorDetail
    {
        /// <summary>
        /// 行号
        /// </summary>
        public int RowNumber { get; set; }

        /// <summary>
        /// 错误信息
        /// </summary>
        public string ErrorMessage { get; set; } = string.Empty;

        /// <summary>
        /// 原始数据
        /// </summary>
        public Dictionary<string, string> OriginalData { get; set; } = new();
    }

    /// <summary>
    /// 物料分类导入预览
    /// </summary>
    public class MaterTypeImportPreview
    {
        /// <summary>
        /// 分类编码
        /// </summary>
        public string TypeCode { get; set; } = string.Empty;

        /// <summary>
        /// 分类名称
        /// </summary>
        public string TypeName { get; set; } = string.Empty;

        /// <summary>
        /// 计量单位
        /// </summary>
        public string Unit { get; set; } = string.Empty;

        /// <summary>
        /// 状态
        /// </summary>
        public int Status { get; set; }

        /// <summary>
        /// 流水号长度
        /// </summary>
        public int Lenght { get; set; }

        /// <summary>
        /// 供应方式
        /// </summary>
        public string SupplyMode { get; set; } = string.Empty;

        /// <summary>
        /// 上级分类编码
        /// </summary>
        public string? ParentCode { get; set; }
    }
}